package com.huqing.icu.rentreport.controller.app;

import com.huqing.icu.base.BaseController;
import com.huqing.icu.base.IdReq;
import com.huqing.icu.rentreport.inout.in.app.ReportRecordAddReq;
import com.huqing.icu.rentreport.inout.in.app.ReportRecordQueryReq;
import com.huqing.icu.rentreport.inout.in.app.ReportTypeConfigQueryReq;
import com.huqing.icu.rentreport.service.app.ReportRecordAddService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description APP新增举报记录接口
 * @Author huqing
 * @Date 2025/4/5 12:49
 **/
@RestController
@RequestMapping("/api/report")
@Tag(name = "APP-新增举报记录接口类")
public class ReportAddController extends BaseController {

    @Autowired
    private ReportRecordAddService reportRecordAddService;

    @Operation(summary = "查询举报记录")
    @RequestMapping(value = "/query_list", method = RequestMethod.POST, produces = "application/json")
    public String queryList(@RequestBody ReportRecordQueryReq queryReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        queryReq.setUserId(userId);
        return jsonSuccess(reportRecordAddService.queryList(queryReq));
    }

    @Operation(summary = "新增举报记录")
    @RequestMapping(value = "/add_report", method = RequestMethod.POST, produces = "application/json")
    public String addReport(@RequestBody ReportRecordAddReq addReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccess(reportRecordAddService.addReport(addReq, userId));
    }

    @Operation(summary = "取消举报")
    @RequestMapping(value = "/cancel_report", method = RequestMethod.POST, produces = "application/json")
    public String cancelReport(@RequestBody IdReq idReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccess(reportRecordAddService.cancelReport(idReq.getId(), userId));
    }

    @Operation(summary = "查询举报配置")
    @RequestMapping(value = "/query_report_config", method = RequestMethod.POST, produces = "application/json")
    public String queryReportConfig(@RequestBody ReportTypeConfigQueryReq queryReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccess(reportRecordAddService.queryReportConfig(queryReq.getBusType(), queryReq.getApplyScene()));
    }

}
